<?php

/* @var $this yii\web\View
 * @var $pageNavi frontend\models\PageNavi
 */

use yii\helpers\Html;
use frontend\models\PageNavi;

?>
<div>
    <?= '分类' ?>
    <br/><hr class="hr-solid"/><br/>
    <a href="/dev/category/create" class="btn">创建分类</a>
    <table class="table-dev table-category" style="margin-top: 20px;">
        <tr>
            <th>ID</th>
            <th>分类名</th>
            <th>描述</th>
            <th></th>
        </tr>
        <?php
        if($list !== null
                && count($list) > 0) {
            foreach($list as $list_item) {
                echo "<tr>";
                echo "<td>" . Html::encode($list_item['id']) . "</td>";
                echo "<td>" . Html::encode($list_item['name']) . "</td>";
                echo "<td>" . Html::encode($list_item['desc']) . "</td>";
                echo "<td><a href=\"/\">编辑</a></td>";
                echo "</tr>";
            }
        }
        ?>

    </table>

    <?php if(isset($pageNavi) && $pageNavi !== null && $pageNavi->hasMorePage()): ?>
        <div class="page-num" style="width: 80%;">
            <br/>
            <div class="pull-right">
                <?php if($pageNavi->current > 1): ?>
                    <a class="page-num-a" href="<?= $pageNavi->getPageUrl($pageNavi->current - 1); ?>">上一页</a>
                <?php endif; ?>
                <?php for($i = $pageNavi->start; $i <= $pageNavi->end; $i++): ?>
                    <?php if($i === $pageNavi->current): ?>
                        <a class="page-num-a page-num-current" href="javascript:void(0);"><?= $i; ?></a>
                    <?php else: ?>
                        <a class="page-num-a" href="<?= $pageNavi->getPageUrl($i); ?>"><?= $i; ?></a>
                    <?php endif; ?>
                <?php endfor; ?>
                <?php if($pageNavi->current < $pageNavi->pageTotal): ?>
                    <a class="page-num-a page-num-next" href="<?= $pageNavi->getPageUrl($pageNavi->current + 1); ?>">下一页</a>
                <?php endif; ?>
            </div>
        </div>
    <?php endif; ?>

</div>